package com.example.wanbaqian.activity;

import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Bundle;
import android.support.annotation.NonNull;

import com.example.wanbaqian.R;
import com.example.wanbaqian.base.BaseActivity;
import com.example.wanbaqian.utils.SPUtils;

import java.util.TimerTask;

/**
 * 冷启动页面
 */
public class WelcomeActivity extends BaseActivity {

    @Override
    protected int getLayout() {
        return R.layout.activity_welcome;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
//        setStatusBarColorInFragment();
        setStatusBarColor(R.color.main_color);


        CountDownTimer tm = new CountDownTimer(1000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {

            }

            @Override
            public void onFinish() {
                if ((boolean) SPUtils.get(mContext, "first", true)) {
                    SPUtils.put(mContext, "first", false);
                    openActivity(SplashActivity.class);
                    finish();
                } else {
                    openActivity(LoginActivity.class);
                    finish();
                }

            }
        };
        tm.start();
        //2017年10月16日15:06:47小米ANR修改
        /*new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if ((boolean) SPUtils.get(mContext, "first", true)) {
                    SPUtils.put(mContext, "first", false);
                    openActivity(SplashActivity.class);
                    finish();
                } else {
                    openActivity(LoginActivity.class);
                    finish();
                }
            }
        }, 1500);*/
    }

    @Override
    protected void initDate() {

    }
}
